import { watcher } from "@feng3d/watcher";
import { RingGeometry } from "../../thirdparty/three/imports";
import { BufferGeometry3D } from "../core/BufferGeometry3D";

export class RingGeometry3D extends BufferGeometry3D
{
    innerRadius = 0.5;
    outerRadius = 1;
    thetaSegments = 32;
    phiSegments = 1;
    thetaStart = 0;
    thetaLength = Math.PI * 2;

    get _geometry()
    {
        if (!this.__geometry)
        {
            this.__geometry = new RingGeometry(this.innerRadius, this.outerRadius, this.thetaSegments, this.phiSegments, this.thetaStart, this.thetaLength);
        }

        return this.__geometry;
    }
    declare protected __geometry: RingGeometry;

    constructor()
    {
        super();
        watcher.watchs(this as RingGeometry3D, ["innerRadius", "outerRadius", "thetaSegments", "phiSegments", "thetaStart", "thetaLength"], this._invalidate, this);
    }

    destroy()
    {
        watcher.unwatchs(this as RingGeometry3D, ["innerRadius", "outerRadius", "thetaSegments", "phiSegments", "thetaStart", "thetaLength"], this._invalidate, this);
    }
}
